//
//  ViewController.m
//  UI_14_午分享_摇一摇
//
//  Created by li cheng on 16/8/2.
//  Copyright © 2016年 li cheng. All rights reserved.
//

#import "ViewController.h"
#import "MyView.h"
@interface ViewController ()
@property (nonatomic, strong) MyView *myView;
@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    _myView = [[MyView alloc] initWithFrame:CGRectMake(10, 10, 100, 100)];
    [self.view addSubview:_myView];
    [_myView canBecomeFirstResponder];
    
}

- (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event{
    // 摇晃开始
    _myView.backgroundColor = [UIColor yellowColor];
}
- (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event{
    // 摇晃结束
    _myView.backgroundColor = [UIColor redColor];
}
- (void)motionCancelled:(UIEventSubtype)motion withEvent:(UIEvent *)event{
    // 摇晃终止
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
